package edu.towson.cis.cosc442.project4.coffeemaker;

import junit.framework.TestCase;

/**
 *
 */
public class CoffeeMakerTest extends TestCase {
	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1, r2;

	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r2 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(3);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);
	}

	public void testAddRecipe1() {
		assertTrue(cm.addRecipe(r1));
	}
	
	public void testCantAddRecipe1() {
		cm.addRecipe(r1);
		assertFalse(cm.addRecipe(r1));
	}
	
	public void testCantAddRecipe5() {
		cm.addRecipe(r1);
		assertFalse(cm.addRecipe(r1));
	}

	public void testDeleteRecipe1() {
		cm.addRecipe(r1);
		assertTrue(cm.deleteRecipe(r1));
	}
	
	public void testDeleteRecipefail() {
		cm.addRecipe(r2);
		assertFalse(cm.deleteRecipe(r2));
	}

	public void testEditRecipe1() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		newRecipe.setAmtSugar(2);
		assertTrue(cm.editRecipe(r1, newRecipe));
	}
	
	public void testEditRecipeFail() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r2;
		newRecipe.setAmtSugar(2);
		assertFalse(cm.editRecipe(r1, newRecipe));
	}
	
	
	public void testmakeCoffee() {
		cm.addRecipe(r1);

		assertEquals(cm.makeCoffee(r1, 60),10);
	}
	
	public void testmakeCoffeeFail() {
		cm.addRecipe(r1);

		assertEquals(cm.makeCoffee(r1, 20),20);
	}
	
	
	public void testmakeCoffeeC() {
		cm.addRecipe(r1);
		cm.makeCoffee(r1, 50);
		assertEquals(cm.inventory.getCoffee(),18);
	}
	
	public void testmakeCoffeeM() {
		cm.addRecipe(r1);
		cm.makeCoffee(r1, 50);
		assertEquals(cm.inventory.getMilk(),14);
	}
	
	public void testmakeCoffeeS() {
		cm.addRecipe(r1);
		cm.makeCoffee(r1, 50);
		assertEquals(cm.inventory.getSugar(),14);
	}
	
	public void testmakeCoffeeCh() {
		cm.addRecipe(r1);
		cm.makeCoffee(r1, 50);
		assertEquals(cm.inventory.getChocolate(),15);
	}
	
	public void testAddInventory() {
		
		assertTrue(cm.addInventory(1,1,0,1));
	}
	
	public void testAddInventoryCoffee() {
		cm.addInventory(1, 1, 0, 1);
		assertEquals(cm.inventory.getCoffee(),16);
	}
	public void testAddInventorySugar() {
		cm.addInventory(1, 1, -1, 1);
		assertEquals(cm.inventory.getSugar(),14);
	}
	public void testAddInventoryMilk() {
		cm.addInventory(1, 1, 0, 1);
		assertEquals(cm.inventory.getMilk(),16);
	}
	public void testAddInventoryChocolate() {
		cm.addInventory(1, 1, 0, 1);
		assertEquals(cm.inventory.getChocolate(),16);
	}
	
	public void testAddInventoryfail_1() {
		assertFalse(cm.addInventory(-1,1,1,1));
	}
	
	public void testAddInventoryfail_2() {
		assertFalse(cm.addInventory(1,-1,1,1));
	}
	public void testAddInventoryfail_3() {
		assertFalse(cm.addInventory(1,1,2,1));
	}
	public void testAddInventoryfail_4() {
		assertFalse(cm.addInventory(0,1,1,-1));
	}
	public void testCheckInventory() {
		
		assertEquals(cm.inventory,cm.checkInventory());
	}
	
	
	public void testGetRecipeForName() {
		cm.addRecipe(r1);
		assertEquals(cm.getRecipeForName("Coffee"),r1);
	}
	
	
	
	
	
	
}